import sys
# To change this template, choose Tools | Templates
# and open the template in the editor.
from Monster_NPC import NPC
import random
import time
class Player():
    def __init__(self,name):
        self.levelData = [0,50,70,130,240,330,450,560,690,840]
        self.itemData = ["Tiaha",50,"RainCaller",23,"FlaxShoe",12,"Kiwi-Coat",14,"GrandMother's JawBone",110]
        self.name = ""
        self.hp = [100,0]
        self.attack = [1,0]
        self.defence = [1,0]
        self.greenstone =0
        self.battling = False
        self.items = []
    def PrintStats(self):
        print("-------------------------")
        print("Hitpoints: "+str(self.hp[0])+":"+str(self.hp[1]))
        print("Attack: "+str(self.attack[0])+":"+str(self.attack[1]))
        print("Defence: "+str(self.defence[0])+":"+str(self.defence[1]))
        print("----------------------------")
    def PrintBag(self):
        print("-------------------------")
        print("GreenStone: "+str(self.greenstone))
        print("Items: "+str(self.items))
        print("----------------------------")
    def Battle(self):
         print("----------------------------")
         self.battling = True
         enemy = NPC(self.attack[0],self.defence[0],(self.hp[0]*3)/2)
         enemy.CreateName()
         while self.battling:
            delay = 0.6
            if self.hp[0] >= 0:
                print("----------------------------")
                print("Enemy Attacks")
                time.sleep(delay)
                damage = random.randint(0,enemy.attack*3)#- random.randint(0,self.defence[0])
                if damage < 0:
                    damage = -damage
                damage *= 5
                self.defence[1] += damage * 2
                self.hp[0] -= damage
                print("You loose "+str(damage)+" Hitpoints")
                print("Your Hitpoints are now "+str(self.hp[0]))
                time.sleep(delay)
            else:
                self.battling = False
                print("----------------------------")
                print("You Died")
                sys.exit(0)
            if enemy.hp >= 0:
                print("----------------------------")
                print("You attack")
                time.sleep(delay)
                damage = random.randint(0,self.attack[0]*3)#- random.randint(0,enemy.defence)
		if damage < 0:
			damage = -damage
                damage *= 5
                self.attack[1] += damage * 2
                self.hp[1] += (damage/5)*2
                enemy.hp -= damage
                print("You Hit "+str(damage)+" Hitpoints")
                print(enemy.name+" Hitpoints are now "+str(enemy.hp))
                time.sleep(delay)
            else:
                self.battling = False
                print("----------------------------")
                print("You've Won")
            self.Update()
            print("----------------------------")
            cont = raw_input("Enter to continue").lower()
            if cont == "n":
                self.battling = False

    def Move(self):
         print("----------------------------")
    def LevelUp(self,skill,newlevel):
        print("**-------------------------**")
        print("You Have Advanced A "+skill+" Level")
        print("You Are Now Level "+str(newlevel)+".")
        print("**----------------------------**")
    def Update(self):
        if self.attack[1] >= self.levelData[self.attack[0]]:
            self.attack[0] += 1
            self.LevelUp("Attack", self.attack[0])
        if self.defence[1] >= self.levelData[self.defence[0]]:
            self.defence[0] += 1
            self.LevelUp("Defence", self.defence[0])
        if self.hp[1] >= self.levelData[self.hp[0]/100]:
            self.hp[0] *= 2
            self.LevelUp("Hitpoints", self.attack[0])


